package com.practice.bootdemo.controller;

import com.practice.bootdemo.agora.rtm.RtmTokenBuilder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :Administrator
 * @description: TODO edit class Description
 * @create date: 2022/1/12 17:30
 */
@Slf4j
@RequestMapping(value = "testGen")
@Api(value="Agora测试 AgoraController",tags={"Agora测试"})
@RestController
public class AgoraController {

    private static String appId = "8b148ddef6184b819c87c3c483d51550";
    private static String appCertificate = "eaa32bf7210d4e28a38aa209a6924e18";
//    private static String userId = "2882341273";
    private static int expireTimestamp = 0;

    @RequestMapping(value = "getRmtToken", method = RequestMethod.GET)
    @ApiOperation(value = "获取Rmt token", httpMethod = "GET")
    public void getRmtToken(String userId) {
        try {
            RtmTokenBuilder token = new RtmTokenBuilder();
            String result = token.buildToken(appId, appCertificate, userId, RtmTokenBuilder.Role.Rtm_User, expireTimestamp);
            System.out.println(" token : "+result);
        } catch (Exception e) {
            log.error("--------->| getRmtToken err | ",e);
        }
    }

    public static void main(String[] args) {
    }
}
